﻿<cfscript>
/** 
* DataBase Frameworks - Sequence
* 
* @hint "DataBase Frameworks - Sequence - BookPublisher" 
*/ 

component 
	displayname="public.service.db.senate.sequence.BookPublisher" 
	output=false 
	accessors=true 
	{

	/**
	* @hint "初始化对象"
	*/
	public function init() output=false {
		return this;
	}
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getID() output=false {
		
		var nextID = numberFormat(1, "0___");
		
		var sql = queryObj = "";
		sql = "	SELECT
					p.pid
				FROM
					t_publisher p
				ORDER BY
					p.pid DESC";
		
		queryObj = new Query(datasource = application.dnsMaster, maxRows = 1);
		rs_check = queryObj.execute(sql = sql).getResult();
		
		/* 
			主键生成规则 CHAR(4)
			
			4位为流水号 出版社自动编码
			
		*/
		if (rs_check.recordCount) {
			/* 创建一个追加id */
			nextID = numberFormat((rs_check.pid + 1), "0___");
			
		}

		return nextID;
	}

}

</cfscript>